﻿package mortal.game.view.copy.wine.view
{
    import Message.Public.*;
    import com.gengine.global.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.vip.*;
    import mortal.game.view.vip.panel.*;
    import mortal.mvc.interfaces.*;

    public class WinePartyResultWin extends ResultBaseWindow
    {
        private var _expItem:BaseItem;
        private var _donateItem:BaseItem;
        private var _exp:BitmapNumberText;
        private var _donate:BitmapNumberText;
        private var _wineTypeImg:GImageBitmap;
        private var _vipExpAddition:GTextFiled;
        private var _vipDonateAddition:GTextFiled;
        private var _vipOpenTips1:VipOpenTipsPanel;
        private var _vipOpenTips2:VipOpenTipsPanel;
        private static var _instance:WinePartyResultWin;

        public function WinePartyResultWin(param1:ILayer = null)
        {
            super(param1);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.WinePartyResultTitle, 200 + 12 + 69 - 53, 21 - 16 - 50, this));
            this._wineTypeImg = UIFactory.gImageBitmap(ImagesConst.WineParty_Level3, 340 - 41 - 53, 50 - 5, this);
            this.pushUIToDisposeVec(UIFactory.bg(330 - 96 - 53 - 40, 83, 336 + 73 + 18, 159, this));
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.WinePartyResultText_GainExp, 139 - 26 + 144 - 53 - 40, 144 + 20 - 51, this));
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.WinePartyResultText_GainDonate, 139 - 26 + 144 - 53 - 40, 144 + 20 + 23, this));
            this._expItem = UICompomentPool.getUICompoment(BaseItem);
            this._expItem.setItemStyle(ItemStyleConst.Big, ImagesConst.ShopItemBg, 6, 6);
            this._expItem.isShowLock = true;
            this._expItem.isDragAble = false;
            this._expItem.x = 170 - 25 + 90 + 171 - 53 - 40;
            this._expItem.y = 173 + 22 - 105;
            this._expItem.itemCode = 180011015;
            this.addChild(this._expItem);
            this._donateItem = UICompomentPool.getUICompoment(BaseItem);
            this._donateItem.setItemStyle(ItemStyleConst.Big, ImagesConst.ShopItemBg, 6, 6);
            this._donateItem.isShowLock = true;
            this._donateItem.isDragAble = false;
            this._donateItem.x = 170 - 25 + 90 + 171 - 53 - 40;
            this._donateItem.y = 173 + 22 - 32;
            this._donateItem.itemCode = 180141006;
            this.addChild(this._donateItem);
            this._exp = UIFactory.bitmapNumberText(120 - 25 + 9 + 381 - 53 - 40, 244 + 22 - 165, "BasePassWinNum.png", 18, 21, -8, this, 12, 0);
            this._vipExpAddition = UIFactory.gTextField("", this._exp.x + this._exp.width + 8 - 20, 244 + 22 - 165, 105, 20, this, GlobalStyle.textFormatLv);
            this._donate = UIFactory.bitmapNumberText(495 - 9 - 53 - 40, 244 + 22 - 92, "BasePassWinNum.png", 18, 21, -8, this, 12, 0);
            this._vipDonateAddition = UIFactory.gTextField("", this._donate.x + this._donate.width + 8 - 20, 244 + 22 - 92, 105, 20, this, GlobalStyle.textFormatLv);
            this._vipOpenTips1 = UICompomentPool.getUICompoment(VipOpenTipsPanel);
            this._vipOpenTips1.valueType = VipOpenTipsPanel.percentValue;
            this._vipOpenTips1.resetLevelTextPos(73 - 39 + 23, 1, 73 - 39, 1);
            this._vipOpenTips1.resetValueTextPos(96 + 17 + 42, 1, 96 + 17, 1);
            this._vipOpenTips1.move(120 - 25 + 9 + 381 - 53 - 40, 244 + 22 - 165 + 25);
            this.addChild(this._vipOpenTips1);
            this._vipOpenTips1.bgUrl = "";
            this._vipOpenTips1.resetTipsTextPos(0, 0, 0, 0);
            this._vipOpenTips1.vipType = EVipRecordType._EVipRecordTypeWineExp;
            this._vipOpenTips2 = UICompomentPool.getUICompoment(VipOpenTipsPanel);
            this._vipOpenTips2.valueType = VipOpenTipsPanel.percentValue;
            var _loc_1:* = Cache.instance.vip.level;
            var _loc_2:* = VipUtil.getVipMinLevelByType(EVipRecordType._EVipRecordTypeWineExp);
            if (_loc_1 < _loc_2)
            {
                this._vipOpenTips2.resetLevelTextPos(73 - 39 + 23, 3, 73 - 39 + 23, 3);
                this._vipOpenTips2.resetValueTextPos(96 + 17 + 42, 3, 96 + 17 + 42, 3);
            }
            else
            {
                this._vipOpenTips2.resetLevelTextPos(73 - 39, 1, 73 - 39, 1);
                this._vipOpenTips2.resetValueTextPos(96 + 17, 1, 96 + 17, 1);
            }
            this._vipOpenTips2.move(495 - 9 - 53 - 40, 244 + 22 - 92 + 25);
            this.addChild(this._vipOpenTips2);
            this._vipOpenTips2.bgUrl = "";
            this._vipOpenTips2.resetTipsTextPos(0, 0, 0, 0);
            this._vipOpenTips2.vipType = 420;
            this.updateRewardInfo();
            this.stageResize();
            return;
        }// end function

        private function updateRewardInfo() : void
        {
            var _loc_4:int = 0;
            var _loc_5:int = 0;
            var _loc_6:int = 0;
            var _loc_7:Number = NaN;
            var _loc_1:* = Cache.instance.copy.wineParty.currWinePartyLevel;
            switch(_loc_1)
            {
                case 1:
                {
                    this._wineTypeImg.imgUrl = ImagesConst.WineParty_Level1;
                    break;
                }
                case 2:
                {
                    this._wineTypeImg.imgUrl = ImagesConst.WineParty_Level2;
                    break;
                }
                case 3:
                {
                    this._wineTypeImg.imgUrl = ImagesConst.WineParty_Level3;
                    break;
                }
                default:
                {
                    this._wineTypeImg.imgUrl = ImagesConst.WineParty_Level1;
                    break;
                    break;
                }
            }
            var _loc_2:* = Cache.instance.copy.wineParty.winePartyDetailInfo;
            if (_loc_2 == null)
            {
                return;
            }
            this._exp.text = "+" + _loc_2.exp;
            this._donate.text = "+" + _loc_2.contribution;
            var _loc_3:* = Cache.instance.vip.level;
            if (_loc_3 == 0)
            {
                this._vipExpAddition.text = "";
                this._vipDonateAddition.text = "";
            }
            else
            {
                _loc_4 = Cache.instance.vip.level;
                _loc_5 = VipUtil.getVipMinLevelByType(EVipRecordType._EVipRecordTypeWineExp);
                if (_loc_4 >= _loc_5)
                {
                    _loc_6 = int(VipConfig.instance.getValueByTypeAndLv(EVipRecordType._EVipRecordTypeWineExp, _loc_4));
                    _loc_7 = _loc_6 / (100 + _loc_6);
                    this._vipExpAddition.text = "[VIP +" + int(_loc_2.exp * _loc_7) + "]";
                    this._vipDonateAddition.text = "[VIP +" + int(_loc_2.contribution * _loc_7) + "]";
                }
                else
                {
                    this._vipExpAddition.text = "";
                    this._vipDonateAddition.text = "";
                }
            }
            this._vipExpAddition.x = this._exp.x + this._exp.width + 8 - 20;
            this._vipDonateAddition.x = this._donate.x + this._donate.width + 8 - 20;
            return;
        }// end function

        private function onExitHandler(event:MouseEvent) : void
        {
            GameProxy.copy.leaveCopy();
            this.hide();
            return;
        }// end function

        override public function show(param1:int = 0, param2:int = 0) : void
        {
            super.show();
            this.stageResize();
            return;
        }// end function

        override public function stageResize() : void
        {
            this.x = (Global.stage.stageWidth - this.width) / 2;
            this.y = (Global.stage.stageHeight - this.height) / 2;
            return;
        }// end function

        override protected function configParams() : void
        {
            _titleSpriteHight = 135;
            super.configParams();
            return;
        }// end function

        override protected function updateBtnSize() : void
        {
            if (_closeBtn)
            {
                _closeBtn.x = 704;
                _closeBtn.y = 8 + 23;
            }
            return;
        }// end function

        override protected function addContentBg() : void
        {
            return;
        }// end function

        override protected function setContentBgSize(param1:int, param2:int) : void
        {
            return;
        }// end function

        override protected function updateSize() : void
        {
            super.updateSize();
            _typeBg.x = _typeBg.x - 10;
            _enterBtn.y = _enterBtn.y + 10;
            return;
        }// end function

        override protected function enterBtnClickHandler(event:MouseEvent) : void
        {
            super.enterBtnClickHandler(event);
            GameProxy.copy.leaveCopy();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl();
            this._exp.dispose();
            this._exp = null;
            this._donate.dispose();
            this._donate = null;
            this._expItem.dispose();
            this._expItem = null;
            this._donateItem.dispose();
            this._donateItem = null;
            this._wineTypeImg.dispose();
            this._wineTypeImg = null;
            this._vipExpAddition.dispose();
            this._vipExpAddition = null;
            this._vipDonateAddition.dispose();
            this._vipDonateAddition = null;
            this._vipOpenTips1.dispose();
            this._vipOpenTips1 = null;
            this._vipOpenTips2.dispose();
            this._vipOpenTips2 = null;
            return;
        }// end function

        public static function get instance() : WinePartyResultWin
        {
            if (_instance == null)
            {
                _instance = new WinePartyResultWin;
            }
            return _instance;
        }// end function

    }
}
